//
//  CooImageApp.swift
//  CooImage
//
//  Created by jerry on 2025/8/16.
//

import SwiftUI

@main
struct CooImageApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .frame(minWidth: 600, minHeight: 400)
        }
        .windowStyle(HiddenTitleBarWindowStyle())
        .commands {
            CommandGroup(replacing: .newItem) {
                Button("打开图片") {
                    NotificationCenter.default.post(name: NSNotification.Name("OpenImage"), object: nil)
                }
                .keyboardShortcut("o", modifiers: .command)
            }
            
            CommandMenu("视图") {
                Button("上一张图片") {
                    NotificationCenter.default.post(name: NSNotification.Name("PreviousImage"), object: nil)
                }
                .keyboardShortcut(.leftArrow, modifiers: [])
                
                Button("下一张图片") {
                    NotificationCenter.default.post(name: NSNotification.Name("NextImage"), object: nil)
                }
                .keyboardShortcut(.rightArrow, modifiers: [])
                
                Divider()
                
                Button("放大") {
                    NotificationCenter.default.post(name: NSNotification.Name("ZoomIn"), object: nil)
                }
                .keyboardShortcut("+", modifiers: .command)
                
                Button("缩小") {
                    NotificationCenter.default.post(name: NSNotification.Name("ZoomOut"), object: nil)
                }
                .keyboardShortcut("-", modifiers: .command)
                
                Button("重置大小") {
                    NotificationCenter.default.post(name: NSNotification.Name("ResetZoom"), object: nil)
                }
                .keyboardShortcut("0", modifiers: .command)
                
                Divider()
                
                Button("顺时针旋转") {
                    NotificationCenter.default.post(name: NSNotification.Name("RotateClockwise"), object: nil)
                }
                .keyboardShortcut("r", modifiers: .command)
                
                Button("逆时针旋转") {
                    NotificationCenter.default.post(name: NSNotification.Name("RotateCounterClockwise"), object: nil)
                }
                .keyboardShortcut("r", modifiers: [.command, .shift])
                
                Divider()
                
                Button("显示/隐藏工具栏") {
                    NotificationCenter.default.post(name: NSNotification.Name("ToggleToolbar"), object: nil)
                }
                .keyboardShortcut("t", modifiers: .command)
            }
        }
    }
}
